// 路由配置文件，定义前端页面路由及权限控制
// 使用Vue Router 4实现页面跳转和路由守卫
import { createRouter, createWebHistory } from 'vue-router'
import GenerateQuestion from '@/pages/ai/GenerateQuestion.vue'
import Login from '@/pages/user/Login.vue'
import Register from '@/pages/user/Register.vue'
import Cookies from 'js-cookie'

const routes = [
  // 主页面，需登录
  { path: '/', name: 'GenerateQuestion', component: GenerateQuestion, meta: { requiresAuth: true } },
  // 聊天页面，复用主页面组件
  { path: '/chat', name: 'Chat', component: GenerateQuestion, meta: { requiresAuth: true } },
  // 用户信息页面，按需加载
  {
    path: '/user/info',
    name: 'UserInfo',
    component: () => import('@/pages/user/UserInfo.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 删除 router.beforeEach 路由守卫

export default router 